import requests
import  re
import json
# 1 先模拟登录
login_url = 'https://www.gying.org/user/login/'
session = requests.Session()

headers = {
    "accept": "*/*",
    "accept-encoding": "gzip, deflate, zstd",
    "accept-language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
    "cache-control": "no-cache",
    "content-length": "84",
    "content-type": "application/x-www-form-urlencoded",
    "cookie": "PHPSESSID=7i0pi8t5268n1lb5u99lf6hn30; vrg_go=1; vrg_sc=f06180ead3751838341b5d605ec85238",
    "origin": "https://www.gying.org",
    "pragma": "no-cache",
    "priority": "u=1, i",
    "referer": "https://www.gying.org/user/login/",
    "sec-ch-ua": "\"Chromium\";v=\"142\", \"Google Chrome\";v=\"142\", \"Not_A Brand\";v=\"99\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36"
}
payload = {
    "siteid": "1",
    "dosubmit": "1",
    "cookietime": "10506240",
    "username": "july76",
    "password": "hardtry..0706"
}
# 2 去请求收藏页面
response = session.post(login_url,headers=headers,data=payload)
url = 'https://www.gying.org/user/favorite'
res = session.get(url)
# print(res.text)
data = re.search(r'_obj.inlist=(.*?);',res.text)
print(data.group(1))

if data:
    data = data.group(1)
    # print(type(data))
    data = json.loads(data)
    titles = data['t']
    images = data['i']

    for i,t in enumerate(titles):
        print(t,f'https://s.tutu.pm/img/mv/{ images[i]}/384.avif')






